<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="author" content="Cheresting" />
  <!-- 自动添加dayjs到全局 -->
  <script src="./publicJs/dayjs.min.js"></script>
  <!-- 自动添加vue到全局 -->
  <script src="./publicJs/vue.global.prod.js"></script>
  <!-- 自动添加axios到全局 -->
  <script src="./publicJs/axios.min.js"></script>
  <!-- 自动添加Cookies到全局 -->
  <script src="./publicJs/js.cookie.min.js"></script>
  <!-- 自动添加XLSX到全局 -->
  <script src="./publicJs/xlsx.core.min.js"></script>

  <link rel="stylesheet" href="./publicJs/element-plus.index.css" />
  <!-- 自动添加ElementPlus到全局 -->
  <script src="./publicJs/element-plus.index.full.js"></script>
  <script src="./publicJs/index.iife.min.js"></script>
  <!-- 添加组件到全局 -->
  <script src="./components/production-order-info.js"></script>
  <script src="./components/production-process-info.js"></script>
  <script src="./components/production-bom-info.js"></script>
  <title>TASKCARD_IN</title>
</head>

<body>
  <div id="app">
    <el-row :gutter="20">
       <el-form
        style="max-width: 600px"
        :model="seForm"
        label-width="auto"
      >
        <el-form-item>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-input
                v-model="seForm.workNumber"
                type="text"
                aria-label="工号"
                placeholder="工号"
              />
            </el-col>
            <el-col :span="12">
              <el-input
                v-model="seForm.serialNumber"
                type="text"
                aria-label="流水号"
                placeholder="流水号"
                @keyup.enter="totalOp"
              />
            </el-col>
          </el-row>
        </el-form-item>
      </el-form>
      <span>
        <el-button type="primary" @click="totalOp">
          <el-icon>
            <Search />
          </el-icon>
          <span>查询</span>
        </el-button>
      </span>

      </el-row>
      <el-row :gutter="20">

                <el-table-v2
                  v-loading="loading"
                  element-loading-text="Loading..."
                  element-loading-background="rgba(122, 122, 122, 0.8)"
                  :columns="columns"
                  :data="data"
                  :width="1350" 
                  :height="300" 
                  border 
                  stripe 
                  fixed
                ></el-table-v2>

        </el-row>      
        <el-row :gutter="20">
                <el-table-v2
                  v-loading="false"
                  element-loading-text="Loading..."
                  element-loading-background="rgba(122, 122, 122, 0.8)"
                  :columns="columns2"
                  :data="data2"
                  :width="1350" 
                  :height="150" 
                  border 
                  stripe 
                  fixed
                ></el-table-v2>
        </el-row>   
  </div>
</body>
<script type="module">
  import useMyXlsx from './hooks/useMyXlsx.js'
  let myXlsx = useMyXlsx()
  import { showSuccess, showWarning } from './hooks/useMyMessageBox.js'
  import myAxios from './myAxios/myAxios.js'
  const { UploadFilled, Search } = ElementPlusIconsVue
  const { ElImage, ElLoading } = ElementPlus
  const { createApp, ref, reactive, computed, h,nextTick } = Vue
  const value1 = ref('')
  const app = createApp({
    name: 'dyxcs',
    components: {
      UploadFilled,
      Search,

    }
    ,
    setup() {
      const seForm = reactive({
        workNumber: '',
        serialNumber: '',
      })
      const data=ref([])
      const data2=ref([])
      const columns=ref([]);
      const columns2=ref([]);
      columns.value=[ {
              Key: 'MATCODE',
              dataKey: 'MATCODE',
              title: '物料编号',
              width: 200,
              align: 'center',
              fixed: 'left',
            },
            {
              Key: 'MATNAME',
              dataKey: 'MATNAME',
              title: '物料名字',
              width: 200,
              align: 'center',
            },
            {
              Key: 'BOMAMOUNT',
              dataKey: 'BOMAMOUNT',
              title: '物料数量',
              width: 300,
              align: 'center',
            },
          
          ]
      columns2.value=[ {
              Key: 'PROSN',
              dataKey: 'PROSN',
              title: '流水号',
              width: 200,
              align: 'center',
              fixed: 'left',
            },
            {
              Key: 'WPNAME',
              dataKey: 'WPNAME',
              title: '配件名',
              width: 200,
              align: 'center',
            },
            {
              Key: 'TOPERATOR',
              dataKey: 'TOPERATOR',
              title: '工号',
              width: 300,
              align: 'center',
            },
            {
              Key: 'CEARDATE',
              dataKey: 'CEARDATE',
              title: '创建时间',
              width: 300,
              align: 'center',
            },
          
          ]        
      const loading=ref(false)
      let getDataBy =function(){
        
        let params=`${seForm.serialNumber}`
        let name='丁允鑫流水号查询1_notCheckKey'
        myAxios.get(name,params,'9900')
        .then((res) => {
          if (res instanceof Array) {
            
              data.value = res
            
            
          } else {
            showWarning('获取数据失败res!' + res)
          }
          
        })
        .catch((err) => {
          
          showWarning('获取数据失败err!' + err)
        })

      }
      let postWorkNum =function(code){
        
        let params=`${seForm.serialNumber}🈹${seForm.workNumber}🈹${code}`
        let name='丁允鑫工号操作录入_notCheckKey'
        myAxios.post(name,params,'9900')
        .then((res) => {
          if(res.includes("成功"))
          {
            showSuccess('录入成功!')
            getRecord();
          }
         

        })
        .catch((err) => {
          
          showWarning('录入数据失败err!' + err)
        })
      }
      
      let getRecord =function(){
        
        let params=`${seForm.serialNumber}🈹${seForm.workNumber}`;
        let name='丁允鑫法兰操作查询_notCheckKey';
        myAxios.get(name,params,'9900')
        .then((res) => {
          if (res instanceof Array) {
            
              data2.value = res
              
            
          } else {
            showWarning('获取数据失败res!' + res)
          }
          
        })
        .catch((err) => {
          
          showWarning('获取数据失败err!' + err)
        })

      }
      const validateForm = () => {
        const workNumber = seForm.workNumber?.trim();
        const serialNumber = seForm.serialNumber?.trim();

        if (!workNumber) {
          showWarning('请输入工号!');
          return false;
        }
        if (!serialNumber) {
          showWarning('请输入流水号!');
          return false;
        }
        return true;
      };
    const totalOp = async () => {
      if (!validateForm()) return;

      try {
        loading.value = true;
        getDataBy();
        await postWorkNum('gd0801');
        await postWorkNum('7190');
        showSuccess('获取成功!');
      } catch (err) {
        showWarning('获取失败: ' + (err.message || err));
      } finally {
        loading.value = false;
      }
    };
    const handleEnter=(event)=>{
       if (event.key === 'Enter') {
          totalOp();
       }
    }

      return {
        value1,
        seForm,
        columns,
        data,
        data2,
        columns2,
        loading,
        getDataBy,
        postWorkNum,
        totalOp,
        getRecord,
        handleEnter,
      }
    },
  })
  
  // 使用Element Plus
  app.use(ElementPlus)
  app.mount('#app')
</script>
<style scoped>

</style>

</html>